<div >
<script>

function monthRecuurChange(type){
	//$('#month_recurr_day').hide();
	//$('#month_recurr_week').hide();
	//$('#month_recurr_'+type).show();
	$('#month_recurr_day').find(':input').attr('disabled','true');
	$('#month_recurr_week').find(':input').attr('disabled','true');
	$('#month_recurr_'+type).find(':input').removeAttr('disabled');
}
function RecuurTypeChange(type){
	$('#schedule-day').hide();
	$('#schedule-week').hide();
	$('#schedule-month').hide();
	$('#schedule-year').hide();
	$('#schedule-'+type).show();
}
function yearRecuurChange(type){
	//$('#year_recurr_day').hide();
	//$('#year_recurr_week').hide();
	//$('#year_recurr_'+type).show();
	$('#year_recurr_day').find(':input').attr('disabled','true');
	$('#year_recurr_week').find(':input').attr('disabled','true');
	$('#year_recurr_'+type).find(':input').removeAttr('disabled');
	
}
function toggleRecurrInfo(checked){
	if(checked){
		$("#schedule-recurr-info").show();
	}
	else{
		$("#schedule-recurr-info").hide();
	}
}
$(function(){
	$("#ScheduleRecurrable").trigger('change');
	
	$("input:radio[name='data[Schedule][recurrencetype]'][value='{{$recurrencetype}}']").attr("checked", 'checked');	
	$("input:radio[name='data[Schedule][year_recurr_type]'][value='{{$year_recurr_type}}']").attr("checked", 'checked');	
	$("input:radio[name='data[Schedule][month_recurr_type]'][value='{{$month_recurr_type}}']").attr("checked", 'checked');	
	yearRecuurChange('{{$year_recurr_type}}');
	monthRecuurChange('{{$month_recurr_type}}');
	RecuurTypeChange('{{$recurrencetype}}');
	
	//$("input:radio[name='data[Schedule][recurrencetype]']").button( "option" , 'data[Schedule][recurrencetype]', '{{$recurrencetype}}' )
	
	//$("#ScheduleRecurrable").trigger('change');
	//$("#ScheduleRecurrable").trigger('change');

	//$("#ScheduleDayTimes").spinner({step:1});
});
</script>

<div class="form">
{{$this->MForm->create('Schedule',array('type'=>'file','class'=>"form-horizontal",'id'=>'form81771538'))}}
<fieldset>
{{if $id}}
<p class="pull-right"><a href="/schedules/delete/{{$id}}" onclick="if(confirm('确认要删除吗？')) return ajaxAction(this.href,null,null,function(request){showSuccessMessage(request.msg);publishController.close_dialog();$('#calendar').fullCalendar( 'refetchEvents' );}); else return false;" class="btn-remove-event btn btn-warning"><i class="fa fa-remove"></i> 删除此日程</a></p>
{{/if}}

<div class="form-inline  form-group form-group"><label for="ScheduleBegintime" class="col-sm-2 control-label">开始时间 </label>
<div class="col-sm-6 controls text">
{{$this->MForm->input('begintime',array('div'=>false,'label'=>false,'type'=>'text','class'=>'form-control datepicker'))}}
</div></div>

{{$this->MForm->input('endtime',array('div'=> 'form-inline  form-group','label'=>'结束时间 ','type'=>'text','class'=>'form-control datepicker'))}}
<div class="form-group form-inline clearfix">
	<label class="col-sm-2 control-label" for="WxMsgCateId">所属分类</label>
	<div class="col-sm-9 controls select">
		{{$this->MForm->input('cate_id',array('class'=>'form-control','div'=>false,'label'=>false))}}
		&nbsp;&nbsp;<a target="_blank" href="{{$this->Html->url(array('controller'=>'user_cates','action'=>'add','Schedule'))}}">新增分类</a>
		&nbsp;&nbsp;<a href="javascript:loadUserCateOptions('#ScheduleCateId','Schedule')" class="showtooltip" title="新增分类后，点击刷新分类，新增的会出现在选项中">刷新分类</a>
		<p>提示：必需创建开放分类才能分享个人的日历数据</p>
	</div>
</div>
		

{{$this->MForm->input('name',array('div'=>'wide form-group','label'=>'标题','class'=>'form-control',))}}

{{$this->MForm->input('strong',array('div'=>'wide form-group','label'=>'是否加粗'))}}

{{$this->MForm->input('message',array('div'=>'wide','rows'=>3,'label'=>'内容','class'=>'wyswyg'))}}
<!--
{{$this->MForm->input('recurrable',array('div'=>'wide form-group','label'=>'是否重复','after'=>'<p>提示：仅付费用户可用重复功能。目前为测试阶段</p>','onchange'=>'toggleRecurrInfo(this.checked);'))}}
-->
<div id="schedule-recurr-info" class=" form-group" style="display:none;">     
     <div class="col-md-3">
     	<div class="show-as-buttonset">
     	 {{$this->MForm->input('recurrencetype', array('legend'=>'重复类型','type'=>'radio','separator'=>'<br/>','onchange'=>'RecuurTypeChange(this.value);','options'=>array('day'=>__('按日重复'),'week'=>__('按周重复'),'month'=>__('按月重复'),'year'=>__('按年重复'))))}}
     	</div>
     </div>
     <div class="col-md-9">
     	<div class="">
	     <div id="schedule-day" class="tab-pane"  style="display:none;">
	     	 <span>{{$this->MForm->input('day_times',array('div'=>false,'label'=>false)) }}</span> {{__('Days once')}}
	     </div>
	     <div id="schedule-week" class="innertabs ui-helper-clearfix" style="display:none;">
	     	 {{$this->MForm->input('week_mon',array('div'=>'left')) }} 
	     	 {{$this->MForm->input('week_tues',array('div'=>'left')) }} 
	     	 {{$this->MForm->input('week_wen',array('div'=>'left')) }} 
	     	 {{$this->MForm->input('week_thur',array('div'=>'left')) }} 
	     	 {{$this->MForm->input('week_fri',array('div'=>'left')) }} 
	     	 {{$this->MForm->input('week_sat',array('div'=>'left')) }} 
	     	 {{$this->MForm->input('week_sun',array('div'=>'left')) }} 
	     </div>
	     <div id="schedule-month" class="tab-pane" style="display:none;">
	     	
	     	<div class="ui-helper-clearfix">
	     		<div class="left">
	     		{{$this->MForm->radio('month_recurr_type',array('day'=>__('recurr by day')),array('onchange'=>'monthRecuurChange(this.value);'))}}
	     		<!-- <input type="radio" name="data[Schedule][month_recurr_type]" id="ScheduleMonthRecurrTypeDay" onchange="monthRecuurChange(this.value);" value="day" checked="checked">
<label for="ScheduleMonthRecurrTypeDay">recurr by day</label>-->
	     		</div>
		     	 <div id="month_recurr_day">
		     	 {{$this->MForm->input('month_calendric',array('div'=>'left','options'=>array('Solar'=>__('Solar'),'Lunar'=>__('Lunar'))))}}
		     	 {{$this->MForm->input('month_day',array('div'=>'left','options'=>array('1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'10'=>10,'11'=>11,'12'=>12,'13'=>13,'14'=>14,'15'=>15,'16'=>16,'17'=>17,'18'=>18,'19'=>19,'20'=>20,'21'=>21,'22'=>22,'23'=>23,'24'=>24,'25'=>25,'26'=>26,'27'=>27,'28'=>28,'29'=>29,'30'=>30,'31'=>31)))}}
		     	 </div>
	        </div>
	        <div class="ui-helper-clearfix">
	     		<div class="left">
	     		{{$this->MForm->radio('month_recurr_type',array('week'=>__('recurr by week')),array('onchange'=>'monthRecuurChange(this.value);'))}}
	     		<!-- <input type="radio" name="data[Schedule][month_recurr_type]" id="ScheduleMonthRecurrTypeWeek" onchange="monthRecuurChange(this.value);" value="week">
<label for="ScheduleMonthRecurrTypeWeek">recurr by week</label> -->
	     		</div>
		     	 <div id="month_recurr_week">
		     	  {{$this->MForm->input('month_weeknum',array('div'=>'left','options'=>array('1'=>__('First'),'2'=>__('Second'),'3'=>__('Thirt'),'4'=>__('Fouth'),'5'=>__('Fifth'))))}}
		     	  {{$this->MForm->input('month_week',array('div'=>'left','options'=>array(__('Sunday'),__('Monday'),__('Tuesday'),__('Wednesday'),__('Thursday'),__('Friday'),__('Saturday'))))}}
		     	 </div>
	        </div>
	     </div>
	     <div id="schedule-year" class="tab-pane" style="display:none;">
	     	 <div class="show-as-buttonset">
	     	 {{$this->MForm->radio('year_recurr_type',array('day'=>__('recurr by day'),'week'=>__('recurr by week')),array('onchange'=>'yearRecuurChange(this.value);'))}}
	     	 </div>
	     	 <div id="year_recurr_day">
	     	 {{$this->MForm->input('year_calendric',array('options'=>array('Solar'=>__('Solar'),'Lunar'=>__('Lunar'))))}}
	     	 {{$this->MForm->input('year_month',array('options'=>array('1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'10'=>10,'11'=>11,'12'=>12)))}}
	     	 {{$this->MForm->input('year_day',array('options'=>array('1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'10'=>10,'11'=>11,'12'=>12,'13'=>13,'14'=>14,'15'=>15,'16'=>16,'17'=>17,'18'=>18,'19'=>19,'20'=>20,'21'=>21,'22'=>22,'23'=>23,'24'=>24,'25'=>25,'26'=>26,'27'=>27,'28'=>28,'29'=>29,'30'=>30,'31'=>31)))}}
	     	 </div>
	     	 <div id="year_recurr_week">
	     	 {{$this->MForm->input('year_week',array('options'=>array(__('Sunday'),__('Monday'),__('Tuesday'),__('Wednesday'),__('Thursday'),__('Friday'),__('Saturday'))))}}
	     	 {{$this->MForm->input('year_weeknum',array('options'=>array('1'=>__('First'),'2'=>__('Second'),'3'=>__('Thirt'),'4'=>__('Fouth'),'5'=>__('Fifth'))))}}
	     	 {{$this->MForm->input('year_weekmonth',array('options'=>array('1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'10'=>10,'11'=>11,'12'=>12)))}}
	     	 </div>
	     </div>
	    </div>
     </div>
</div>
</fieldset><div class="form-group">
		<label class="col-sm-2 control-label" for="ProductName"></label>
		<div class="col-sm-9"><input class="btn btn-primary" id="btnsubmit" type="submit" value="提交"></div>
	</div>
</form>
</div>
<script type="text/javascript">
$(function(){	
	if(current_editor){
		current_editor.destroy();
	}
	current_editor = UE.getEditor('ScheduleMessage',{
          	initialFrameHeight:150,
          	focus:true,
           focusInEnd:true
    });
});
</script>

</div>